package com.leosoft.heatmonitor.model;

import java.sql.Timestamp;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;

import com.leosoft.heatmonitor.model.tool.JsonDateSerializer;

@Entity
@Table(name = "dataheat", catalog = "heatMonitor")
@DynamicInsert
@DynamicUpdate
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class DataHeat implements java.io.Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 7648385215879211106L;
	private String id;
	private String projectId;
	private String projectName;
	private String deviceKey;
	private String targetKey;
	private String building;
	private String door;
	private String user;

	private Timestamp createtime;
	private Project project;

	private String status;
	private Double allflow;
	private Double allheat;
	private Double lastheat;
	private Double currentflow;
	private Double currentHeat;

	@Column(name = "currentheat", nullable = false)
	public Double getCurrentHeat() {
		return currentHeat;
	}

	public void setCurrentHeat(Double currentHeat) {
		this.currentHeat = currentHeat;
	}

	private Double inTemperature;
	private Double outTemperature;
	private String errorCode;

	@Column(name = "targetKey", nullable = false, length = 20)
	public String getTargetKey() {
		return targetKey;
	}

	public void setTargetKey(String targetKey) {
		this.targetKey = targetKey;
	}

	@GenericGenerator(name = "generator", strategy = "uuid")
	@GeneratedValue(generator = "generator")
	@Id
	@Column(name = "id", unique = true, nullable = false, length = 32)
	public String getId() {
		return id;
	}

	@Column(name = "status", nullable = false, length = 10)
	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	@Column(name = "allflow", nullable = false)
	public Double getAllflow() {
		return allflow;
	}

	public void setAllflow(Double allflow) {
		this.allflow = allflow;
	}

	@Column(name = "allheat", nullable = false)
	public Double getAllheat() {
		return allheat;
	}

	public void setAllheat(Double allheat) {
		this.allheat = allheat;
	}

	@Column(name = "lastheat", nullable = false)
	public Double getLastheat() {
		return lastheat;
	}

	public void setLastheat(Double lastheat) {
		this.lastheat = lastheat;
	}

	@Column(name = "currentflow", nullable = false)
	public Double getCurrentflow() {
		return currentflow;
	}

	public void setCurrentflow(Double currentflow) {
		this.currentflow = currentflow;
	}

	@Column(name = "inTemperature", nullable = false)
	public Double getInTemperature() {
		return inTemperature;
	}

	public void setInTemperature(Double inTemperature) {
		this.inTemperature = inTemperature;
	}

	@Column(name = "outTemperature", nullable = false)
	public Double getOutTemperature() {
		return outTemperature;
	}

	public void setOutTemperature(Double outTemperature) {
		this.outTemperature = outTemperature;
	}

	@Column(name = "errorCode", nullable = false, length = 20)
	public String getErrorCode() {
		return errorCode;
	}

	public void setErrorCode(String errorCode) {
		this.errorCode = errorCode;
	}

	public void setId(String id) {
		this.id = id;
	}

	@Column(name = "projectid", nullable = false, length = 32)
	public String getProjectId() {
		return projectId;
	}

	public void setProjectId(String projectId) {
		this.projectId = projectId;
	}

	@Column(name = "projectName", nullable = false, length = 30)
	public String getProjectName() {
		return projectName;
	}

	public void setProjectName(String projectName) {
		this.projectName = projectName;
	}

	@Column(name = "deviceKey", nullable = false, length = 20)
	public String getDeviceKey() {
		return deviceKey;
	}

	public void setDeviceKey(String deviceKey) {
		this.deviceKey = deviceKey;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@JsonSerialize(using = JsonDateSerializer.class)
	public Date getCreatetime() {
		return createtime;
	}

	public void setCreatetime(Timestamp createtime) {
		this.createtime = createtime;
	}

	@Column(name = "building", nullable = true, length = 20)
	public String getBuilding() {
		return building;
	}

	public void setBuilding(String building) {
		this.building = building;
	}

	@Column(name = "door", nullable = true, length = 20)
	public String getDoor() {
		return door;
	}

	public void setDoor(String door) {
		this.door = door;
	}

	@Column(name = "user", nullable = true, length = 20)
	public String getUser() {
		return user;
	}

	public void setUser(String user) {
		this.user = user;
	}

	@ManyToOne(targetEntity = Project.class)
	@JoinColumn(name = "projectId")
	public Project getProject() {
		return project;
	}

	public void setProject(Project project) {
		this.project = project;
	}

}
